package com.dong.demo222.config;

import com.dong.demo222.domin.SysUser;
import com.dong.demo222.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

@Component
public class UserDetailServiceImpl implements UserDetailsService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        SysUser sysUser = sysUserMapper.selectUserByUsername(username);


        return User.withUsername(sysUser.getUserName())
                .password(sysUser.getPassword())
                .authorities("query")
                .roles("qqq")
                .build();


    }


}
